package com.ywu.sentinel.sdk.api;

import com.ywu.common.result.CommonResult;
import com.ywu.sentinel.sdk.dto.YwuBlowRuleDto;
import com.ywu.sentinel.sdk.dto.YwuFlowRuleDto;
import com.ywu.sentinel.sdk.dto.YwuHotRuleDto;
import com.ywu.sentinel.sdk.dto.YwuSystemRuleDto;
import com.ywu.sentinel.sdk.service.FlowRuleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName FlowRuleApi
 * @Description TODO
 * @Author GroundDemo
 * @Date 2025/4/14 16:46
 * @Version 1.0
 **/
@RestController
@RequestMapping("/ywu/sentinel/rule/sdk")
public class FlowRuleApi {

    @Autowired
    private FlowRuleService service;

    /**
    * @Author GroundDemo
    * @Description 加载流控规则
    * @Date 0:15 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/sentinel.flow.rule.create")
    public CommonResult<Object> flowRuleCreate(@RequestBody YwuFlowRuleDto ruleDto) {
        return service.flowRuleCreate(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 删除规则
    * @Date 8:47 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/sentinel.flow.rule.delete")
    public CommonResult<Object> flowRuleDelete(@RequestBody YwuFlowRuleDto ruleDto) {
        return service.flowRuleDelete(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 修改流控规则
    * @Date 13:44 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/sentinel.flow.rule.update")
    public CommonResult<Object> flowRuleUpdate(@RequestBody YwuFlowRuleDto ruleDto) {
        return service.flowRuleUpdate(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 加载熔断规则
    * @Date 9:25 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/sentinel.blow.rule.create")
    public CommonResult<Object> blowRuleCreate(@RequestBody YwuBlowRuleDto ruleDto) {
        return service.blowRuleCreate(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 删除熔断规则
     * @Date 8:47 2025/4/15
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/sentinel.blow.rule.delete")
    public CommonResult<Object> blowRuleDelete(@RequestBody YwuBlowRuleDto ruleDto) {
        return service.blowRuleDelete(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 修改熔断规则
    * @Date 13:46 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/sentinel.blow.rule.update")
    public CommonResult<Object> blowRuleUpdate(@RequestBody YwuBlowRuleDto ruleDto) {
        return service.blowRuleUpdate(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 加载热点规则
    * @Date 9:28 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/sentinel.hot.rule.create")
    public CommonResult<Object> hotRuleCreate(@RequestBody YwuHotRuleDto ruleDto) {
        return service.hotRuleCreate(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 删除热点规则
     * @Date 8:47 2025/4/15
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/sentinel.hot.rule.delete")
    public CommonResult<Object> hotRuleDelete(@RequestBody YwuHotRuleDto ruleDto) {
        return service.hotRuleDelete(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 修改热点规则
    * @Date 13:46 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/sentinel.hot.rule.update")
    public CommonResult<Object> hotRuleUpdate(@RequestBody YwuHotRuleDto ruleDto) {
        return service.hotRuleUpdate(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 加载系统规则
    * @Date 9:30 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/sentinel.system.rule.create")
    public CommonResult<Object> systemRuleCreate(@RequestBody YwuSystemRuleDto ruleDto) {
        return service.systemRuleCreate(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 删除系统规则
     * @Date 8:47 2025/4/15
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/sentinel.system.rule.delete")
    public CommonResult<Object> systemRuleDelete(@RequestBody YwuSystemRuleDto ruleDto) {
        return service.systemRuleDelete(ruleDto);
    }

    /**
    * @Author GroundDemo
    * @Description 修改系统规则
    * @Date 13:47 2025/4/15
    * @Param [ruleDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/sentinel.system.rule.update")
    public CommonResult<Object> systemRuleUpdate(@RequestBody YwuSystemRuleDto ruleDto) {
        return service.systemRuleUpdate(ruleDto);
    }

    /**
     * @Author GroundDemo
     * @Description 查询当前微服务所有的规则信息
     * @Date 8:47 2025/4/15
     * @Param [ruleDto]
     * @return com.ywu.common.result.CommonResult<java.lang.Object>
     **/
    @PostMapping("/sentinel.common.rule.list.info")
    public CommonResult<Object> commonRuleListInfo() {
        return service.commonRuleListInfo();
    }

}
